<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags"  %>
<script type="text/javascript">
$.unblockUI();
$(function() {
	$('#userPersonName').autocomplete({
		source: "./datosjson/searchUserPersons",
		minLength: 2,
		select: function( event, ui ) {
			$('#idUserPerson').val(ui.item.id);
			$('#userPersonName').css('background-color', '#787878');
			$('#userPersonName').attr('readonly', 'true');
		}
	});
});

function limpiarBusqueda()
{
	$('#idUserPerson').val('');
	$('#userPersonName').val('');
	$('#userPersonName').removeAttr("readonly");
	$('#userPersonName').css('background-color', 'white');
}

$("#rolForm").validate({
	submitHandler: function(form) {
		$.post('./userperson/saveUserPerson', $('#rolForm').serialize(), function(resultadoHTML) {
			$('#content').html(resultadoHTML);			
		});
	}
});
</script>
<h4>
	Set Rol:
</h4>
<br>
<s:form id="rolForm" action="./userperson/saveUserPerson" >
	<s:hidden name="userPerson.id" id="idUserPerson"/>
	<s:textfield name="userPersonName" label = "User" id="userPersonName"/>
	<tr><td><s:a cssClass="btn btn-mini" href="#" onclick="limpiarBusqueda()">Change User</s:a></td><td></td></tr>
	<s:select name="idRol" list="rols" listValue="name" listKey="id" label="Rol"></s:select>
	<s:submit cssClass="btn btn-success" id="botSave" align="left" value="Save"/>
</s:form>